<?php

$config_path =  BASE_PATH . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR;

$config = new \Phalcon\Config();

if($handle = opendir($config_path)){
    while($file = readdir($handle)){
        $info = pathinfo($file);
        if(isset($info['extension']) && $info['extension'] === 'php'){
            $data = require ($config_path . DIRECTORY_SEPARATOR . $file);
            if(is_array($data)){
                $config->merge(new \Phalcon\Config([$info['filename'] => $data]));
            }
        }
    }
}

return $config;